using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._SpatialAnalystTools._Generalization
{
    /// <summary>
    /// <para>Majority Filter</para>
    /// <para>Replaces cells in a raster based on the majority of their contiguous neighboring cells.</para>
    /// <para>根据栅格中的大多数相邻像元替换栅格中的像元。</para>
    /// </summary>    
    [DisplayName("Majority Filter")]
    public class MajorityFilter : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public MajorityFilter()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_raster">
        /// <para>Input raster</para>
        /// <para><xdoc>
        ///   <para>The input raster to be filtered based on the majority of contiguous neighboring cells.</para>
        ///   <para>It must be of integer type.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>要根据大多数相邻像元进行过滤的输入栅格。</para>
        ///   <para>它必须是整数类型。</para>
        /// </xdoc></para>
        /// </param>
        /// <param name="_out_raster">
        /// <para>Output raster</para>
        /// <para><xdoc>
        ///   <para>The output filtered raster.</para>
        ///   <para>The output is always of integer type.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>输出过滤栅格。</para>
        ///   <para>输出始终为整数类型。</para>
        /// </xdoc></para>
        /// </param>
        public MajorityFilter(object _in_raster, object _out_raster)
        {
            this._in_raster = _in_raster;
            this._out_raster = _out_raster;
        }
        public override string ToolboxName => "Spatial Analyst Tools";

        public override string ToolName => "Majority Filter";

        public override string CallName => "sa.MajorityFilter";

        public override List<string> AcceptEnvironments => ["autoCommit", "cellSize", "cellSizeProjectionMethod", "compression", "configKeyword", "extent", "geographicTransformations", "mask", "outputCoordinateSystem", "scratchWorkspace", "snapRaster", "tileSize", "workspace"];

        public override object[] ParameterInfo => [_in_raster, _out_raster, _number_neighbors.GetGPValue(), _majority_definition.GetGPValue()];

        /// <summary>
        /// <para>Input raster</para>
        /// <para><xdoc>
        ///   <para>The input raster to be filtered based on the majority of contiguous neighboring cells.</para>
        ///   <para>It must be of integer type.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>要根据大多数相邻像元进行过滤的输入栅格。</para>
        ///   <para>它必须是整数类型。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input raster")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_raster { get; set; }


        /// <summary>
        /// <para>Output raster</para>
        /// <para><xdoc>
        ///   <para>The output filtered raster.</para>
        ///   <para>The output is always of integer type.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>输出过滤栅格。</para>
        ///   <para>输出始终为整数类型。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output raster")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _out_raster { get; set; }


        /// <summary>
        /// <para>Number of neighbors to use</para>
        /// <para><xdoc>
        ///   <para>Determines the number of neighboring cells to use in the kernel of the filter.</para>
        ///   <bulletList>
        ///     <bullet_item>Four— The kernel of the filter will be the four direct (orthogonal) neighbors to the present cell. This is the default.</bullet_item><para/>
        ///     <bullet_item>Eight— The kernel of the filter will be the eight nearest neighbors (a three-by-three window) to the present cell.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>确定要在筛选器内核中使用的相邻单元格数。</para>
        ///   <bulletList>
        ///     <bullet_item>四— 过滤器的内核将是当前单元格的四个直接（正交）邻居。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>八— 过滤器的内核将是当前单元格的八个最近邻居（一个 3×3 窗口）。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Number of neighbors to use")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _number_neighbors_value _number_neighbors { get; set; } = _number_neighbors_value._FOUR;

        public enum _number_neighbors_value
        {
            /// <summary>
            /// <para>Four</para>
            /// <para>Four— The kernel of the filter will be the four direct (orthogonal) neighbors to the present cell. This is the default.</para>
            /// <para>四— 过滤器的内核将是当前单元格的四个直接（正交）邻居。这是默认设置。</para>
            /// </summary>
            [Description("Four")]
            [GPEnumValue("FOUR")]
            _FOUR,

            /// <summary>
            /// <para>Eight</para>
            /// <para>Eight— The kernel of the filter will be the eight nearest neighbors (a three-by-three window) to the present cell.</para>
            /// <para>八— 过滤器的内核将是当前单元格的八个最近邻居（一个 3×3 窗口）。</para>
            /// </summary>
            [Description("Eight")]
            [GPEnumValue("EIGHT")]
            _EIGHT,

        }

        /// <summary>
        /// <para>Replacement threshold</para>
        /// <para><xdoc>
        ///   <para>Specifies the number of contiguous (spatially connected) cells that must be of the same value before a replacement will occur.</para>
        ///   <bulletList>
        ///     <bullet_item>Majority— A majority of cells must have the same value and be contiguous. Three out of four or five out of eight connected cells must have the same value.</bullet_item><para/>
        ///     <bullet_item>Half— Half of the cells must have the same value and be contiguous. Two out of four or four out of eight connected cells must have the same value. This option will have a more smoothing effect than the other.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定在进行替换之前必须具有相同值的连续（空间连接）像元数。</para>
        ///   <bulletList>
        ///     <bullet_item>多数 - 大多数单元格必须具有相同的值并且是连续的。四个或八个连接单元中的五个必须具有相同的值。</bullet_item><para/>
        ///     <bullet_item>一半 - 一半的像元必须具有相同的值并且是连续的。四个或八个连接单元中的四个必须具有相同的值。此选项将比其他选项具有更平滑的效果。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Replacement threshold")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _majority_definition_value _majority_definition { get; set; } = _majority_definition_value._MAJORITY;

        public enum _majority_definition_value
        {
            /// <summary>
            /// <para>Majority</para>
            /// <para>Majority— A majority of cells must have the same value and be contiguous. Three out of four or five out of eight connected cells must have the same value.</para>
            /// <para>多数 - 大多数单元格必须具有相同的值并且是连续的。四个或八个连接单元中的五个必须具有相同的值。</para>
            /// </summary>
            [Description("Majority")]
            [GPEnumValue("MAJORITY")]
            _MAJORITY,

            /// <summary>
            /// <para>Half</para>
            /// <para>Half— Half of the cells must have the same value and be contiguous. Two out of four or four out of eight connected cells must have the same value. This option will have a more smoothing effect than the other.</para>
            /// <para>一半 - 一半的像元必须具有相同的值并且是连续的。四个或八个连接单元中的四个必须具有相同的值。此选项将比其他选项具有更平滑的效果。</para>
            /// </summary>
            [Description("Half")]
            [GPEnumValue("HALF")]
            _HALF,

        }

        public MajorityFilter SetEnv(int? autoCommit = null, object cellSize = null, object compression = null, object configKeyword = null, object extent = null, object geographicTransformations = null, object mask = null, object outputCoordinateSystem = null, object scratchWorkspace = null, object snapRaster = null, double[] tileSize = null, object workspace = null)
        {
            base.SetEnv(autoCommit: autoCommit, cellSize: cellSize, compression: compression, configKeyword: configKeyword, extent: extent, geographicTransformations: geographicTransformations, mask: mask, outputCoordinateSystem: outputCoordinateSystem, scratchWorkspace: scratchWorkspace, snapRaster: snapRaster, tileSize: tileSize, workspace: workspace);
            return this;
        }

    }

}